/*
 *  SableJBDD, a Java Binary Decision Diagram package.
 *  Copyright (C) 2003  Feng Qian
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
//$Id: JBddVariable.java,v 1.8 2003/08/12 16:26:37 fqian Exp $

package SableJBDD.bdd;
/**
 * A bdd variable has name, order, and so on.
 *
 * @author Feng Qian
 */

public final class JBddVariable {
  // bdd variables can only be made from a factory to guarantee
  // the uniqueness of each variable
  JBddVariable(String name, int level) {
    this.name = name;
    this.hcode = level;  // init order is used as cache, it is unique
    this.level = level;
  }

  public int hashCode() {
    return this.hcode;   // the number is unique for each variable
  }

  public boolean equals(Object other) {
    return this == other;
  }

  public int getLevel() {
    return this.level;
  }

  void setLevel(int level) {
    this.level = level;
  }

  public String toString() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }
  ////////////////////////////
  // implementation
  ////////////////////////////
  final private int hcode;    // hash code
  private int level;     // position in the order
  private String name;   // the variable name
}
